﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Dispatcher.Converters
{
    class ShortTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var time = (TimeSpan)value;
            return time.ToString("hh':'mm");
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TimeSpan result;
            if (TimeSpan.TryParse((string)value, out result)) return result;
            return null;
        }
    }
}
